package org.store.book;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.apache.wicket.Application;
import org.apache.wicket.Session;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.request.Request;
import org.apache.wicket.request.Response;
import org.store.book.model.Book;
import org.store.book.pages.Index;

/**
 * Application object for your web application. If you want to run this
 * application without deploying, run the Start class.
 * 
 * @see org.store.book.Start#main(String[])
 */
public class BSApplication extends WebApplication {

	private List<Book> bookList = Arrays.asList(new Book("Three mistakes",
			"Chetan Bhagat", 500.00), new Book("Harry Potter", "J.K.Rowling",
			1500.00), new Book("Oxford Dictionary", "Oxford", 1099.00));

	/**
	 * @see org.apache.wicket.Application#getHomePage()
	 */
	@Override
	public Class<? extends WebPage> getHomePage() {
		return Index.class;
	}

	/**
	 * @see org.apache.wicket.Application#init()
	 */
	@Override
	public void init() {
		super.init();
	}

	public final Session newSession(Request request, Response response) {
		return new BookStoreSession(request);

	}

	public List<Book> getBookList() {
		return Collections.unmodifiableList(bookList);
	}

	public void setBookList(List<Book> bookList) {
		this.bookList = bookList;
	}

	public static BSApplication get() {
		return (BSApplication) Application.get();
	}
}
